package com.zhuidian.mothernote.activity;

import android.app.Fragment;
import android.view.View;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.base.presenter.BasePresenter;
import com.base.view.MyTabWidget;
import com.zhuidian.mothernote.R;
import com.zhuidian.mothernote.fragment.QuestionFragment;
import com.zhuidian.mothernote.fragment.UserFragment;
import com.zhuidian.mothernote.global.BaseActivity;

public class SearchCompleteActivity extends BaseActivity {
    private LinearLayout ll_search;
    private EditText et_search;
    private LinearLayout ll_cancel;
    private TextView tv_cancel;
    private TextView tv_answer;
    private TextView tv_user;
    private FrameLayout fl_search_content;
    private MyTabWidget myTabWidget;

    @Override
    protected int inflateMainLayoutId() {
        return R.layout.activity_search_complete;
    }

    @Override
    protected void initView(View view) {
        setTopGone();
        ll_search = (LinearLayout) view.findViewById(R.id.ll_search);
        et_search = (EditText) view.findViewById(R.id.et_search);
        ll_cancel = (LinearLayout) view.findViewById(R.id.ll_cancel);
        tv_cancel = (TextView) view.findViewById(R.id.tv_cancel);
        tv_answer = (TextView) view.findViewById(R.id.tv_answer);
        tv_user = (TextView) view.findViewById(R.id.tv_user);
        fl_search_content = (FrameLayout) view.findViewById(R.id.fl_search_content);
        myTabWidget = (MyTabWidget) view.findViewById(R.id.myTabWidget);
        QuestionFragment questionFragment = new QuestionFragment();
        UserFragment userFragment = new UserFragment();
        initMultiFragment(R.id.fl_search_content, new Fragment[]{questionFragment, userFragment});
        myTabWidget.setSelectionChangedListener(new MyTabWidget.OnMyTabSelectionChanged() {
            @Override
            public void onTabSelectionChanged(int tabIndex, boolean clicked) {
                switchFragment(tabIndex);
            }
        });
    }

    @Override
    protected void setListener() {
        ll_cancel.setOnClickListener(this);
        tv_answer.setOnClickListener(this);
        tv_user.setOnClickListener(this);
    }

    @Override
    protected BasePresenter getPresenter() {
        return null;
    }

    @Override
    public void onClick(View view) {
        super.onClick(view);
        switch (view.getId()) {
            case R.id.tv_answer:
                switchFragment(0);
                break;
            case R.id.tv_user:
                switchFragment(1);
                break;

            case R.id.ll_cancel:
                onBackPressed();
                break;
        }
    }
}
